Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move from MailDateFormat (not thread safe) to DateTimeFormatter #590 #713

Closed
wants to merge 2 commits into from

Conversation

jbescos
Copy link
Member

@jbescos jbescos commented Feb 28, 2024

#590

I only saw references in MimeMessage. I updated that class to not use MailDateFormat.

return mailDateFormat.parse(s);
}
} catch (ParseException pex) {
return Date.from(Instant.from(mailDateFormat.parse(s)));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MailDateFormat has a concept of isLenient and per the API documents it was not clear to me if the default is lenient or strict. I wonder if you need to use withResolverStyle to set that behavior and how compatible with existing behavior, mainly with parsing of dates.

Looking at the MailDateFormatTest there are some tests that seem to imply leniency with lots of exceptions:

  1. lenientMustBeBackwardCompatible()
  2. mustUseLeniencyForParsing()
  3. mustFailOrSkipCfws()
  4. lenientMustAcceptNonMilitaryZoneNames()

I would think that for testing this version of the patch you would need to port the MailDateFormatTest into the MimeMessageTest. Which seems like a lot of work.

What are your thoughts on just getting rid of the static field and the synchronized block and just creating some method local garbage by just creating a new MailDateFormat for parsing and formatting?

@jbescos
Copy link
Member Author

jbescos commented Mar 1, 2024

I don't see a feasible way to replace MailDateFormat, and it has many specifics. Probably moving to DateTimeFormatter is not the way to go.

@jbescos jbescos closed this Mar 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants